#pragma once
#include<iostream>
#include <string>

enum 
{
    DEFAULT1,
    MUL_0,

};
template <class T>
class Task
{
    const static std::string opers;

public:
    Task() {};
    Task(T data1, T data2, char op)
        :_data1(data1),_data2(data2), _op(op), _exitcode(DEFAULT1), _result(T())
    {}
    ~Task() {}
    const static std::string get_op()
    {
        return opers;
    }
    void run()
    {
        switch (_op)
        {
        case '+':
            _result = _data1 + _data2;
            break;
        case '-':
            _result = _data1 - _data2;
            break;
        case '*':
            _result = _data1 * _data2;
            break;
        case '/':
            if (_data2 == T())
                _exitcode = MUL_0;
            else
                _result = _data1 / _data2;
            break;
        case '%':
            if (_data2 == T())
                _exitcode = MUL_0;
            else
                _result = _data1 % _data2;
            break;
        default:
            _exitcode = DEFAULT1;
            break;
        }
    }
    void operator()()
    {
        run();
    }
    std::string gettask()
    {
        std::string r = std::to_string(_data1);
        r += _op;
        r += std::to_string(_data2);
        r += "=?";
        return r;
    }
    std::string getresult()
    {
        std::string r = std::to_string(_data1);
        r += _op;
        r += std::to_string(_data2);
        r+="=";
        r += std::to_string(_result);
        r += "[code:";
        r += std::to_string(_exitcode);
        r += "]";
        return r;
    }

private:
    T _data1;
    T _data2;
    T _result;
    int _exitcode;
    char _op;
};
template <class T>
const std::string Task<T>::opers = "+-*/%";
